package File;

import java.awt.event.FocusEvent;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;

public class FileList {
    public static void main(String[] args) throws IOException {
        /*
        File file = new File("./demo.txt");
        String name = file.getName();
        System.out.println(name);

        long len = file.length();
        System.out.println("length:"+len);

        boolean ih = file.isHidden();
        boolean ac = file.canRead();
        boolean ij = file.canWrite();
        System.out.println(ih);
        System.out.println(ac);
        System.out.println(ij);
         */
        /*
        File dir = new File(".");
        if (dir.isDirectory()) {
            FileFilter filter = new FileFilter() {
                @Override
                public boolean accept(File file) {
                    String name = file.getName();
                    return name.endsWith(".txt");
                }
            };

            File[] subs = dir.listFiles(filter);
            for (File sub : subs) {
                System.out.println(sub.getName());
            }
        }
        */

        /*
        for (int i=0;i<10;i++){
            File file = new File("./test"+i+".txt");
            if (!file.exists()){
                file.createNewFile();
            }
        }
        System.out.println("创建完毕");

        File dir = new File(".");
        if (dir.isDirectory()){
            File[] subs = dir.listFiles(file -> file.getName().endsWith(".txt"));
            for (File sub : subs){
                System.out.println(sub.getName());
            }
        }
         */
        /*
        //File file = new File("./test.txt");
        //File f = new File("./demo");
        //file f = new File("./a/b/c");
        File f= new File("./a");
        if (f.exists()){
            f.delete();
            System.out.println("已删除");
        }else{
            System.out.println("文件不存在");
        }
         */
        /*
        File dir = new File("./src");
        if (dir.isDirectory()){
            File[] subs = dir.listFiles();
            System.out.println("当前目录项目下共有："+subs.length+"个子项");
            for (File sub:subs){
                System.out.println(sub.getName());
            }
        }
        */
        /*
        File dir = new File("./demo");
        if (dir.exists()){
            System.out.println("该目录已存在");
        }else{
            dir.mkdirs();
            System.out.println("该目录已创建");
        }

         */
         /*
        File file = new File("./demo.txt");
        String name = file.getName();
        System.out.println(name);

        long len = file.length();
        System.out.println("length:"+len);

        boolean ih = file.isHidden();
        boolean ac = file.canRead();
        boolean ij = file.canWrite();
        System.out.println(ih);
        System.out.println(ac);
        System.out.println(ij);
         */
        /*
        File dir = new File(".");
        if (dir.isDirectory()) {
            FileFilter filter = new FileFilter() {
                @Override
                public boolean accept(File file) {
                    String name = file.getName();
                    return name.endsWith(".txt");
                }
            };

            File[] subs = dir.listFiles(filter);
            for (File sub : subs) {
                System.out.println(sub.getName());
            }
        }
        */

        /*
        for (int i=0;i<10;i++){
            File file = new File("./test"+i+".txt");
            if (!file.exists()){
                file.createNewFile();
            }
        }
        System.out.println("创建完毕");

        File dir = new File(".");
        if (dir.isDirectory()){
            File[] subs = dir.listFiles(file -> file.getName().endsWith(".txt"));
            for (File sub : subs){
                System.out.println(sub.getName());
            }
        }
         */
        /*
        //File file = new File("./test.txt");
        //File f = new File("./demo");
        //file f = new File("./a/b/c");
        File f= new File("./a");
        if (f.exists()){
            f.delete();
            System.out.println("已删除");
        }else{
            System.out.println("文件不存在");
        }
         */
        /*
        File dir = new File("./src");
        if (dir.isDirectory()){
            File[] subs = dir.listFiles();
            System.out.println("当前目录项目下共有："+subs.length+"个子项");
            for (File sub:subs){
                System.out.println(sub.getName());
            }
        }
        */
        /*
        File dir = new File("./demo");
        if (dir.exists()){
            System.out.println("该目录已存在");
        }else{
            dir.mkdirs();
            System.out.println("该目录已创建");
        }

         */





    }

}
